<template>
	<div class="my">
		<view>
			<input class="inputStyle" placeholder="标题" disabled="" v-model="stu.title" />
		</view>
		<view>
			<textarea class="inputStyle" placeholder="内容" v-model="stu.text"/>
		</view>
		<view v-show="isShow">
			<button type="default" form-type="submit" class="loginBtn" @click="login">确认修改</button>
		</view>
	</div>
</template>

<script>
	const {updateNews} = require('../../utils/admin.js')
	export default {
		data() {
			return {
				isShow:false,
				stu:{
					id:'',
					title:'',
					text:''
				}
			}
		},
		created() {
			this.stu = uni.getStorageSync('item');
			if(uni.getStorageSync('identity') === 'teacher'){
				this.isShow = true;
			}else{
				this.isShow = false;
			}
		},
		methods:{
			login(){
				updateNews(this.stu).then(data=>{
					uni.showModal({
						content: data.msg,
						showCancel: false
					});
					if(data.code === 200){
						uni.$emit('storage_news',{data:data.data})
						uni.switchTab({
							url: 'index'
						});
					}
				})
			},
		}
	}
</script>

<style scoped src="../../static/css/my.css"></style>
<style scoped src="../../static/css/service.css"></style>
